package com.shijiangdiya.code.controller;

import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.google.common.base.Supplier;
import com.shijiangdiya.code.entity.User;
import com.shijiangdiya.code.service.UserService;
import com.shijiangdiya.code.service.impl.UserServiceImpl;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import com.shijiangdiya.config.Response;


import com.shijiangdiya.config.AbstractController;

import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shijiangdiya
 * @since 2023-09-23
 */
@RestController
@RequestMapping(value = {"/api/user"},
		produces = MediaType.APPLICATION_JSON_VALUE)
@Api(value = "UserController", description = "", produces = MediaType.APPLICATION_JSON_VALUE)
public class UserController extends AbstractController {
    @Autowired
    private UserService userService;

    @ResponseBody
    @ApiOperation(value = "", notes = "")
    @GetMapping(value = "/")
    public Response select(){
        List select = userService.select();
        return returnSuccess();
    }

    @ResponseBody
    @ApiOperation(value = "", notes = "")
    @PostMapping(value = "")
    public Response add(){
        userService.add();
        return returnSuccess();
    }

    @ResponseBody
    @ApiOperation(value = "", notes = "")
    @PutMapping(value = "/{id}")
    public Response update(@PathVariable Long id){
        userService.modifyById();
        return returnSuccess();
    }

    @ApiOperation(value = "-删除", notes = "-删除")
    @DeleteMapping(value = "/{id}")
    public Response delete(@PathVariable Long id){
        userService.deleteById(id);
        return returnSuccess();
    }

}
